<template>
  <a-config-provider :locale="zh_CN">
    <div id="app">
      <router-view />
    </div>
  </a-config-provider>
</template>

<script>
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';
import { getUserPower, getUserInfo } from '@/api/index'
import { mapGetters } from "vuex";
import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');
export default {
  data() {
    return {
      zh_CN,
    };
  },
  computed: {
    ...mapGetters(["token"]),
  },
  // watch: {
  //   token: {
  //     handler(v) {
  //       if (v) {
  //         this.getUserPower()
  //         this.getUserInfo()
  //       }
  //     },
  //     immediate: true,
  //   }
  // },
  methods: {
    // 获取权限
    getUserPower() {
      getUserPower().then(res => {
        let power = []
        for (let key in res.data) {
          if (res.data[key]) {
            power.push(key)
          }
        }
        this.$store.commit('SET_POWER', power)
      })
    },
    // 获取用户信息
    getUserInfo() {
      getUserInfo().then(res => {
        this.$store.commit('SET_USERINFO', res.data)
      })
    },
  }
};
</script>

<style lang="scss">
/**自定义滚动条样式 */
::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

::-webkit-scrollbar-track {
  background-color: transparent;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb {
  background-color: #9c9da0;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  border-radius: 2px;
}
</style>
